package design.p6_adapter.c2_toObject;

import design.p6_adapter.c1_toClass.Source;
import design.p6_adapter.c1_toClass.Targetable;

/**
 * @ClassName: Java
 * @description:
 * @author: zxf
 * @create: 2021-06-18 11:21
 **/
public class Wrapper implements Targetable {

    private Source source;


    public Wrapper(Source source){
        this.source = source;
    }

    @Override
    public void method1() {
        source.method1();
    }

    @Override
    public void method2() {
        System.out.println("this is targetAble method~~~");
    }

    public static void main(String[] args) {
        Wrapper wrapper = new Wrapper(new Source());
        System.out.println(wrapper.hashCode());
    }
}
// 基本思路和类的适配器模式相同，只是将Adapter类作修改，这次不继承Source类，而是持有Source类的实例，以达到解决兼容性的问题。

